<?php

namespace App\Http\Controllers\Platform;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Resources\Common\DatasResource;
use App\Services\Platform\SettlementService;

class SettlementController extends Controller
{

    /**
     * 导出数据【天】
     */
    public function exportDay(Request $request)
    {
        SettlementService::create()->day($request, true);
    }

    /**
     * 导出数据【月】
     */
    public function exportMonth(Request $request)
    {
        SettlementService::create()->month($request, true);
    }

    /**
     * 导出数据【USD】
     */
    public function exportUsd(Request $request)
    {
        SettlementService::create()->getUsd($request, true);
    }

    /**
     * 获取数据列表【天】
     */
    public function day(Request $request)
    {
        list ($collection, $total, $stats) = SettlementService::create()->day($request);

        return DatasResource::make($collection)->setPaginateTotal($total)->setAttribute('stats', $stats);
    }

    /**
     * 获取数据列表【月】
     */
    public function month(Request $request)
    {
        list ($collection, $total, $stats) = SettlementService::create()->month($request);

        return DatasResource::make($collection)->setPaginateTotal($total)->setAttribute('stats', $stats);
    }

    /**
     * 获取平台统计USD
     */
    public function getUsd(Request $request)
    {
        list ($collection, $stats) = SettlementService::create()->getUsd($request);

        return DatasResource::make($collection)->setAttribute('stats', $stats);
    }
}
